import { createRouter, createWebHistory } from 'vue-router'
import HomeView from '../views/Home/MianLayout.vue'

const routes = [
  {
    path: '/',
    name: 'libraryIndex',
    component: () => import('../views/Index/LibraryIndex.vue')
  },
  {
    path: '/home',
    name: 'home',
    component: HomeView,
  },
  {
    path: '/borrow',
    name: 'Borrows',
    component: () => import('../views/Borrows/BorrowApply.vue')
  },
  {
    path: '/MyBorrows',
    name: 'MyBorrows',
    component: () => import('../views/Borrows/MyBorrows.vue')
  },
  {
    path: '/login',
    name: 'login',
    component: () => import('../views/Login/MyLogin.vue')
  },
  {
    path: '/register',
    name: 'register',
    component: () => import('../views/Register/MyRegister.vue')
  },
  {
    path: '/box',
    name: 'box',
    component: () => import('../components/BoxDiv.vue')
  },
  {
    path: '/userprofile',
    name: 'userprofile',
    component: () => import('../views/UserProfile/UserProfile.vue')
  },
  {
    path: '/MianLayout',
    name: 'MianLayout',
    meta: { breadcrumb: ['首页'] },
    component: () => import('@/views/Home/MianLayout.vue'),
    children: [
      {
        path: 'userlist',   // 这里是首页（默认子路由）
        name: 'userlist',
        meta: { breadcrumb: ['用户管理','用户列表'] },
        component: () => import('../views/Home/components/UserList/UserList.vue')
      },
      {
        path: 'borrow',
        name: 'borrow',
        meta: { breadcrumb: ['借阅管理', '借阅详情'] },
        component: () => import('../views/Home/components/Borrow/BorrowManagement.vue')
      },
      {
        path: 'book',
        name: 'bookManagement',
        meta: { breadcrumb: ['图书管理','图书列表'] },
        component: () => import('@/views/Home/components/Book/BookManagement.vue')
      },
      {
        path: 'bookAdd',
        name: 'BookAdd',
        meta: { breadcrumb: ['图书管理','添加图书'] },
        component: () => import('@/views/Home/components/Book/BookAdd.vue')
      },
    ]
  },

]

const router = createRouter({
  history: createWebHistory(process.env.BASE_URL),
  routes
})

export default router
